﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class UserCenter_user_EditPassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!object.Equals(Session["UserName"], null))
        {}
        else
        {
            //Response.Redirect("user_login.aspx");
            Response.Write("<script>window.open('user_Login.aspx')</script>");
        }
    }
    // 修改密码
    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        try
        {
            if (!object.Equals(Session["UserName"], null))
            {
                String oldPass = this.TextBox1.Text.Trim().ToString();
                String newPass = this.TextBox2.Text.Trim().ToString();

                BLL.Business.UserBLL userBLL = new BLL.Business.UserBLL();
                if (userBLL.UpdatePassword(Session["UserName"].ToString(), oldPass, newPass))
                {
                    Response.Write("<script>alert('修改成功！')</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改失败，请查证！')</script>");
                }
            }
            else
            {
                //Response.Redirect("user_login.aspx");
                Response.Write("<script>window.open('user_login.aspx')</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message.ToString() + "')</script>");
        }
    }

    
}
